<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <script>
        async function fun1() {
            // return 4
            // return Promise.resolve('success')
            // return Promise.reject('fail')
            return new Error('something error')
        }

        let promise = fun1()

        promise.then(
            function(data){
                console.log('执行成功，结果为：' + data)
            },
            function(data){
                console.log('执行失败，结果为：' + data)
            }
        )

        /*------------------------------------------------------------------------------------------------------------*/
        async function fun2() {
            // return 10
            // return Promise.resolve('成功')
            return Promise.reject('失败')
        }

        async function handle() {
            try {
                let data = await fun2();
                console.log('执行结果为：' + a)
            } catch (error) {
                console.log('执行失败，异常捕获：' + error)
            }
            
        }

        handle()
    </script>
</head>
<body>
    
</body>
</html>